export const emoji = () => {
  return (target: any, key: string) => {
    let val = target[key];
    const getter = () => {
      return val;
    };
    const setter = (value: string) => {
      val = `^_^${value}^_^`;
    };
    Object.defineProperty(target, key, {
      get: getter,
      set: setter,
      enumerable: true,
      configurable: true,
    });
  };
};

export const confirmable = (message: string) => {
  return (target: any, key: string, descriptor: PropertyDescriptor) => {
    let originFun = descriptor.value;
    if (message) {
      descriptor.value = (...args: any) => {
        let allow = window.confirm(message);
        if (allow) {
          let result = originFun.apply(this, args);
          return result;
        }
        return null;
      };
    }
  };
};
